package tests;

import static org.junit.Assert.assertFalse;

import org.junit.Test;

import utils.Node;
import utils.TreeUtils;

public class SearchTest {	

	@Test
	public final void testSearch() {
		Node tree = new Node(1, "salut", null, null);
		
		Node toSearch = new Node(2, "buna", tree, null);
		
		tree.children.add(toSearch);
		tree.children.add(new Node(3, "buna2", tree, null));
		tree.children.add(new Node(4, "buna", tree, null));
		tree.children.add(new Node(5, "buna4", tree, null));
		
		assertFalse(TreeUtils.search(tree, toSearch) == null);
		TreeUtils.printTree(tree, "");
		System.out.println("Search: " + TreeUtils.searchById(tree, 2));
		assertFalse(TreeUtils.searchById(tree, 2) == null);
		assertFalse(TreeUtils.searchByLabel(tree, "buna").size() != 2);
		
		
		TreeConstants.init();

		tree = TreeConstants.configuration;
		TreeUtils.printTree(tree, "");
		System.out.println("Search: " + TreeUtils.searchById(tree, 543));
	}

}
